/*jslint maxerr: 50, indent: 4, browser: true */
/*global define */

(function () {
    "use strict";

    define("array.length", ["mergeModules", "init", "isFinite", "object.hasOwnProperty"], function (make) {
        var buri = make.mergeModules(arguments),
            config = {
                "compatability": {}
            },
            func = [].constructor.prototype.length,
            length;

        if (!config.compatability.all && !config.compatability["array.length"] && typeof func === "number" && func === 0) {
            length = function (array) {
                return array.length;
            };
        } else {
            length = function (array) {
                var l = 0,
                    i,
                    t;

                for (i in array) {
                    if (buri.object.hasOwnProperty(array, i) && buri.isFinite(i)) {
                        t = +i;
                        if (t > l) {
                            l = t + 1;
                        }
                    }
                }

                return l;
            };
        }

        length.init = function (options) {
            buri.init(config, options);
            buri.object.hasOwnProperty(config);
        };

        return {
            "array": {
                "length": length
            }
        };
    });
}());
